<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>角色</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
  <link rel="stylesheet" href="/static/layuiadmin/style/template.css" media="all">
  <link rel="stylesheet" href="__ICON__">
  <style>
    .layadmin-address ul{
        padding-top: 15px;
    }
  </style>
</head>
<body>


<div class="layui-fluid layadmin-maillist-fluid">
  <div class="layui-row layui-col-space15">
    {foreach $list as $v}
    <div class="layui-col-md4 layui-col-sm6">
      <div class="layadmin-contact-box" >
        
        <div class="layui-col-md12 layadmin-padding-left20 layui-col-sm6">
          <a href="javascript:;">
            <h3 class="layadmin-title">
              <strong>{$v.title}</strong>
            </h3>
          </a>
          <p class="layadmin-textimg">
            <span class="iconfont icon-bieming"></span>
            {$v.alias}
          </p>
          <p class="layadmin-text">
            {$v.desc}
          </p>
          <div class="layadmin-address">
              <ul>
                <div class="layui-btn-container">
                  <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs layuiadmin-btn-role" data-type="edit" data-id="{$v.id}">编辑</a>
                  <a lay-href="/power/userNode.html?id={$v.id}" lay-text="{$v.title} - 节点" class="layui-btn layui-btn-primary layui-btn-xs">设置权限</a>
                </div>
              </ul>
              <ul>
                {$v.create_time}
              </ul>
          </div>
        </div>
      </div>
    </div>
    {/foreach}
  </div>
</div>


  <script src="/static/layuiadmin/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '/static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index','admin'],function () {
    var $ = layui.$;
    var admin = layui.admin;


    //事件
    var active = {
      edit: function(othis){
        var id = othis.data('id');
        layer.open({
          type: 2
          ,title: '编辑角色'
          ,content: '/power/roleForm.html?id='+id
          ,area: ['500px', '300px']
          ,btn: ['确定', '取消']
          ,yes: function(index, layero){
            var iframeWindow = window['layui-layer-iframe'+ index]
                    ,submit = layero.find('iframe').contents().find("#LAY-user-role-submit");

            //监听提交
            iframeWindow.layui.form.on('submit(LAY-user-role-submit)', function(data){
              var field = data.field; //获取提交的字段
              //提交 Ajax 成功后，静态更新表格中的数据
              //$.ajax({});
              admin.req({
                url: '/power/editRole'
                , type: "POST"
                , data: field
                , done: function (res) {
                  layer.msg('设置成功', {icon: 1, time: 1000}, function () {
                    location.reload();
                    layer.close(index); //关闭弹层
                  });
                },not_finish:function (res) {
                  layer.msg(res.msg);
                }
              });
            });
            submit.trigger('click');
          }
        });
      }
    }
    $('.layui-btn.layuiadmin-btn-role').on('click', function(){
      var type = $(this).data('type');
      var othis = $(this);
      active[type] ? active[type].call(this,othis) : '';
    });
  });
  </script>
</body>
</html>